package mya.mes.mdc.model.tag;

import com.alibaba.fastjson.JSONObject;
import mya.mes.mdc.model.tag.convert.MdcTagConverter;
import mya.mes.mdc.model.tag.util.KeyBuilder;


public class MdcTag {
  public String key;
  /**
   * 车间
   */
  public String shop;

  /**
   * 区域
   */
  public String area;

  /**
   * 段
   */
  public String section;

  public String tagPrefix;

  public int tagIndex;

  public String tagName;

  public String plcAddress;

  public String plcTagType;

  public String dataType;

  public String description;

  public AlarmTag alarmTag = null;

  public String viewTagName;

  public boolean digitsTag = false;

  public boolean posteTag = false;

  public boolean startRunningTag = false;

  public boolean stopRunningTag = false;

  /**
   * 设备生产模式
   */
  public boolean statusProdTag = false;

  /**
   * 设备维护模式
   */
  public boolean statusMaintTag = false;

  public ViewTag viewTag;

  public MdcTag() {
  }

  public MdcTag(JSONObject json) {
    MdcTagConverter.fromJson(json, this);
  }

  public JSONObject toJson() {
    JSONObject json = new JSONObject();
    MdcTagConverter.toJson(this, json);
    return json;
  }

  public String buildKey() {
    if (key == null) {
      key = KeyBuilder.key(shop, area, viewTagName);
    }
    return key;
  }

  public String getKey() {
    return key;
  }

  public void setKey(String key) {
    this.key = key;
  }

  public String getShop() {
    return shop;
  }

  public void setShop(String shop) {
    this.shop = shop;
  }

  public String getArea() {
    return area;
  }

  public void setArea(String area) {
    this.area = area;
  }

  public String getSection() {
    return section;
  }

  public void setSection(String section) {
    this.section = section;
  }

  public String getTagPrefix() {
    return tagPrefix;
  }

  public void setTagPrefix(String tagPrefix) {
    this.tagPrefix = tagPrefix;
  }

  public int getTagIndex() {
    return tagIndex;
  }

  public void setTagIndex(int tagIndex) {
    this.tagIndex = tagIndex;
  }

  public String getTagName() {
    return tagName;
  }

  public void setTagName(String tagName) {
    this.tagName = tagName;
  }

  public String getPlcAddress() {
    return plcAddress;
  }

  public void setPlcAddress(String plcAddress) {
    this.plcAddress = plcAddress;
  }

  public String getPlcTagType() {
    return plcTagType;
  }

  public void setPlcTagType(String plcTagType) {
    this.plcTagType = plcTagType;
  }

  public String getDataType() {
    return dataType;
  }

  public void setDataType(String dataType) {
    this.dataType = dataType;
  }

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public AlarmTag getAlarmTag() {
    return alarmTag;
  }

  public void setAlarmTag(AlarmTag alarmTag) {
    this.alarmTag = alarmTag;
  }

  public String getViewTagName() {
    return viewTagName;
  }

  public void setViewTagName(String viewTagName) {
    this.viewTagName = viewTagName;
  }

  public boolean isDigitsTag() {
    return digitsTag;
  }

  public void setDigitsTag(boolean digitsTag) {
    this.digitsTag = digitsTag;
  }

  public boolean isPosteTag() {
    return posteTag;
  }

  public void setPosteTag(boolean posteTag) {
    this.posteTag = posteTag;
  }

  public boolean isStartRunningTag() {
    return startRunningTag;
  }

  public void setStartRunningTag(boolean startRunningTag) {
    this.startRunningTag = startRunningTag;
  }

  public boolean isStopRunningTag() {
    return stopRunningTag;
  }

  public void setStopRunningTag(boolean stopRunningTag) {
    this.stopRunningTag = stopRunningTag;
  }

  public boolean isStatusProdTag() {
    return statusProdTag;
  }

  public void setStatusProdTag(boolean statusProdTag) {
    this.statusProdTag = statusProdTag;
  }

  public boolean isStatusMaintTag() {
    return statusMaintTag;
  }

  public void setStatusMaintTag(boolean statusMaintTag) {
    this.statusMaintTag = statusMaintTag;
  }

}
